#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: change.py 
@version:
@time: 2024/01/14 
"""
import pdb

count1 = [4, 0, 2, 2, 0, 3, 5]
value1 = [1, 2, 5, 10, 20, 50, 100]
money1 = 234


def change(value, count, money):
    re = 0
    for i in range(len(value) - 1, -1, -1):
        # 当前金额除以当前面额
        # 当前面额数量
        # 去最小值赋值给num
        num = min(int(money / value[i]), count[i])
        # 金额=金额-减去当前面额数量*当前面额价值
        money = money - num * value[i]
        # 结果等于面额相加
        re += num

    if money > 0:
        return -1
    return re


result = change(value1, count1, money1)
print(result)
